package com.litchi.Repository;

import com.litchi.Model.Project;
import com.litchi.Model.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;


public interface  ProjectRepository extends JpaSpecificationExecutor<Project>,JpaRepository<Project, Integer> {

    @Query("select u.userName as userName, u.nickName as nickName, u.email as email,p.userId as userId, p.projectName as projectName from User u , Project p where u.id = p.userId")
    List<UserInfo> findInner();

    @Query("select u.userName as userName, u.nickName as nickName, u.email as email,p.userId as userId, p.projectName as projectName from User u , Project p where u.id = p.userId and  u.id = ?1")
    UserInfo findByUserId(Integer id);

}
